import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class Demo8 {

    public static void main(String[] args) {
        try (Reader reader = new FileReader("./demo")){
            while (true){
                char[] b = new char[3];

                int n = reader.read(b,0,2);
                if (n == -1){
                    //文件读完
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.println(b[i]);
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main2(String[] args) {
        try (Reader reader = new FileReader("./demo")){
            while (true){
                char[] b = new char[3];

                int n =reader.read(b);
                if (n == -1){
                    //文件读完
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.println(b[i]);
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main1(String[] args) {
        try(Reader reader = new FileReader("./demo") ){
            while (true){
                int n = reader.read();
                if (n == -1){
                    break;
                }
                System.out.printf("%x\n",n);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
